/*
 *  JDiv - API for Multimedia Application
 *  http://jdiv.sourceforge.net 
 *  ------------------------------------
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software 
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 *
 */

package com.jdiv;

import com.jdiv.kernel.JDivSystem;

/** These are the processes that will interact in JDiv, which are fundamental in this API. <p>
  * This processes type run "loop ()" to "loop ()", ie each cycle calls "loop()" of process function, so that the function is executed again from the beginning.*/

public abstract class ProcessLoop extends Process
{
	   
	  public ProcessLoop() 
	  {
		  super();
	  }
	  
	  /**
	   * Run the ProcessLoop, <b>please do not use this feature</b> because it can cause permanent errors in execution. It is used by the core JDiv so no need to use this function.
	   */
	  
	  public void runCode(){
		  
		  loop( JDivSystem.deltaRun );
		  
		  frameEnd();
	  }
	  
	  
	  /**
	   * <P>Method where the code is implemented the process to run on every frame.</P>
	   * <p><b>Warning:</b> Not implement the "run method" use this.</p>
	   */
	  
	 abstract public void loop( float delta );
	 
	 /**
	   * <P>Method Process class destroyer, remove data to finish running.</P>
	   */
	 
	 abstract public void dispose();

	   
	  /**
	   * Prevents running the loop a certain time..
	   * @param timeSeconds Time to wait to next frame.
	   */
	  
	  public void notRunLoop( float timeSeconds ) {
		  reserved.timeWaitFrame = timeSeconds;
	  }
	   
	  /**
	   * Stops the process can not rerun anymore, <b>please do not use this feature</b> because it can cause permanent errors in execution. Use for stop of Process: this.setSignal (Const.SIGNAL_KILL);
	   */
	  
	  public void disposeProcess( ){
		   
		   getReserved().psStatus = Const.SIGNAL_KILL;

	  }
	  
	  
	  
	
}
